package com.hualan.zhsq.controller.car;

import com.hualan.zhsq.entity.car.Region;
import com.hualan.zhsq.service.car.RegionService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName RegionController
 * @Description 区域管理controller
 * @Author ZheRan
 * @Date 2025年08月03日 下午5:04
 * @Version 1.0
 */
@RestController
public class RegionController {
    @Qualifier("regionService")
    @Autowired
    private RegionService regionService;

    //插入一条数据
   @PostMapping("/region/add")
    public Result add(@RequestBody Region region) {
       return Result.success(regionService.add(region));
   }

   //逻辑删除一条数据
    @DeleteMapping("/region/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        return Result.success(regionService.remove(id));
    }

    //批量逻辑删除数据
    @DeleteMapping("/region/removeBatch")
    public Result removeBatch(@RequestBody Integer[] ids) {
        return Result.success(regionService.removeBatch(ids));
    }

    //修改一条数据
    @PutMapping("/region/edit")
    public Result edit(@RequestBody Region region) {
        return Result.success(regionService.edit(region));
    }

   //根据id查询数据
    @GetMapping("/region/findById/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(regionService.findById(id));
    }

    //查询所有数据
    @GetMapping("/region/findPage")
    public Result findPage() {
        return Result.success(regionService.findPage(1, 10, new Region()));
    }


}

